﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Pyramid.Extentions;

namespace Pyramid.Models
{
	/// <summary>
	/// 考勤记录主表
	/// </summary>
	public class AttendanceMaster
	{
		public int Id { get; set; }

		[Display(Name = "年份")]
		public int Year { get; set; }

		[Display(Name = "月份")]
		public int Month { get; set; }

		[Display(Name = "本月应出勤天数")]
		public int ExpectedDays { get; set; }

		[Display(Name = "状态")]
		public int Status { get; set; }

		[NotMapped]
		public string StatusString { get { return ((DataStatus) Status).ToDescription(); } }

		[Display(Name = "建档日期")]
		public DateTime CreateTime { get; set; }

		[Display(Name = "建档人")]
		[MaxLength(20)]
		public string CreateUserId { get; set; }

		[Display(Name = "最后修改时间")]
		public DateTime EditTime { get; set; }

		[Display(Name = "最后修改人")]
		[MaxLength(20)]
		public string EditUserId { get; set; }

		public virtual ICollection<AttendanceDetail> AttendanceDetails { get; set; }
	}

	/// <summary>
	/// 考勤记录从表
	/// </summary>
	public class AttendanceDetail
	{
		public int Id { get; set; }
		public int StaffId { get; set; }

		[Display(Name = "本月出勤天数")]
		public int ActualDays { get; set; }

		public int MasterId { get; set; }

		[ForeignKey("StaffId")]
		public virtual Staff Staff { get; set; }

		[ForeignKey("MasterId")]
		public virtual AttendanceMaster Master { get; set; }
	}
}